﻿using System.ComponentModel.DataAnnotations;

namespace MediPlatform.Domain.Order
{
    /// <summary>
    /// 退款申请主表
    /// </summary>
    public class RefundApplication
    {
        /// <summary>
        /// 主键，自增
        /// </summary>
        [Key]
        public long? Id { get; set; }

        /// <summary>
        /// 唯一退款申请编号
        /// </summary>
        [StringLength(64)]
        public string? ApplicationNo { get; set; }

        /// <summary>
        /// 外键，关联订单表（如药品订单、挂号订单等）
        /// </summary>
        public long? OrderId { get; set; }

        /// <summary>
        /// 用户ID，外键关联用户表
        /// </summary>
        public long? UserId { get; set; }

        /// <summary>
        /// 用户导航属性
        /// </summary>
        public virtual User? User { get; set; }

        /// <summary>
        /// 申请退款金额
        /// </summary>
        [Range(0, double.MaxValue)]
        public decimal? Amount { get; set; }

        /// <summary>
        /// 退款申请状态：0-待处理, 1-已处理, 2-已拒绝
        /// </summary>
        public int? Status { get; set; }

        /// <summary>
        /// 申请时间
        /// </summary>
        public DateTime? ApplyTime { get; set; }

        /// <summary>
        /// 处理完成时间（审核通过或拒绝时填写）
        /// </summary>
        public DateTime? ProcessTime { get; set; }

        /// <summary>
        /// 处理人员ID，外键关联员工表（如客服、财务等）
        /// </summary>
        public long? ProcessorId { get; set; }

        /// <summary>
        /// 处理备注（如拒绝原因）
        /// </summary>
        public string? Remark { get; set; }

        /// <summary>
        /// 退款渠道：original（原支付渠道），other（其他方式）
        /// </summary>
        [StringLength(50)]
        public string? RefundChannel { get; set; } = "original";

        /// <summary>
        /// 退款类型：cancel_order（取消订单），return_goods（退货退款），others（其他）
        /// </summary>
        [StringLength(50)]
        public string? RefundType { get; set; } = "cancel_order";

        /// <summary>
        /// 扩展信息，如退款来源（挂号预约、图文问诊等）
        /// </summary>
        public string? ExtraInfo { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreatedAt { get; set; } = DateTime.Now;

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime? UpdatedAt { get; set; } = DateTime.Now;
    }
}
